package Frame.screen;

import FCRendering.FCRConstants;
import FCRendering.FCRMaster;
import FCRendering.ImageUtil;
import FCRendering.sw.FCRValues;
import Frame.entity.UnifyShopSayUIEntity;
import Function.Utils.SwingUtil;

import java.awt.*;

import static FCRendering.FCRMaster.fcv;

public class UseItemScreen extends IScreen{
    Font font1;

    @Override
    public void dispatchPaintComponent(Graphics g, FCRMaster fcrMaster) {
        if(fcv.isOpenUseItem() || fcv.isOpenTanCheResult() || fcv.isOpenMMWVIP()){
            g.drawImage(ImageUtil.getImage("gamesayshop"), (int) (532 * fcv.getProportion()), (int) (581 * fcv.getProportion()),
                    (int) (856 * fcv.getProportion()), (int) (343 * fcv.getProportion()), this);

            int startX = 556;
            int dx = 0;
            int textY = 0;
            //宽是400  425
            for (int i = 0; i < 6; i++) {
                UnifyShopSayUIEntity leftUi = FCRValues.leftWindowUI[i];
                UnifyShopSayUIEntity rightUi = FCRValues.rightWindowUI[i];

                textY = (int) (641 * fcv.getProportion()+47 * i * fcv.getProportion());
                //左边
                g.setFont(font1);
                g.setColor(Color.white);
                if(fcv.getMouseX() > (int) ((startX)* fcv.getProportion()) && fcv.getMouseX() < (int) ((startX+400)* fcv.getProportion())){
                    if(fcv.getMouseY() > (int)(textY-37*fcv.getProportion())&& fcv.getMouseY() < (int)(textY+10*fcv.getProportion())) {
                        g.setColor(Color.BLUE);
                    }
                }

                dx = (int)(350* fcv.getProportion()- SwingUtil.getStringWidht(leftUi.rightText, font1));
                g.drawString(leftUi.leftText, (int) ((startX+20)* fcv.getProportion()),textY);
                g.drawString(leftUi.rightText,(int) (dx + startX * fcv.getProportion()),textY);

                //右边
                g.setColor(Color.white);
                if(fcv.getMouseX() > (int) ((startX + 425)* fcv.getProportion()) && fcv.getMouseX() < (int) ((startX+ 425+400)* fcv.getProportion())){
                    if(fcv.getMouseY() > (int)(textY-37*fcv.getProportion())&& fcv.getMouseY() < (int)(textY+10*fcv.getProportion())) {
                        g.setColor(Color.BLUE);
                    }
                }

                dx = (int)(350* fcv.getProportion()-SwingUtil.getStringWidht(rightUi.rightText, font1));
                g.drawString(rightUi.leftText, (int) ((startX+20+425)* fcv.getProportion()),textY);
                g.drawString(rightUi.rightText,(int) (dx + (startX+425) * fcv.getProportion()),textY);
            }
        }
    }

    @Override
    protected void setBounds() {
        font1 = new Font(FCRConstants.FONT_ELEGANT_BLACK, 0, (int) (24 * fcv.getProportion()));
    }
}
